import { defineConfig } from 'vite';
import uni from '@dcloudio/vite-plugin-uni';
import AutoImport from 'unplugin-auto-import/vite';
import AutoComponent from 'unplugin-vue-components/vite';
import tllPlugin from './vitePlugins/tllPlugin';

// https://vitejs.dev/config/
export default defineConfig(({mode}) => {
  return {
    plugins: [
      uni(),
      //自动读取tabbar配置
      tllPlugin({mode}),
      //自动引入组件,在src/components下面,'tll-'开头的组件会自动引入
      AutoComponent({
        dts: true,
        globs: ['src/components/tll-*.{vue}'],
      }),
      //自动引入api
      AutoImport({
        imports: [
          {
            '@/hooks/useGetPageQuery': ['useGetPageQuery'], // import {useGetPageQuery} from "@/hooks/useGetPageQuery"
            '@/hooks/useGetNavInfo': [['default', 'useGetNavInfo']], // import {default as useGetNavInfo} from "@/hooks/useGetNavInfo"
            '@/hooks/useGetNavbarOpacity': ['useGetNavbarOpacity'], // import {useGetNavbarOpacity} from "@/hooks/useGetNavbarOpacity"
            '@/utils/helper': [['*', 'helper']], // import {default as helper} from "@/utils/helper"
            '@/utils/typeIs': [['*', 'typeIs']], // import {* as typeIs} from "@/utils/typeIs"
            '@/utils/interaction': [['*', 'interaction']], // import {* as interaction} from "@/utils/interaction"
            '@/utils/utils': [['*', 'utils']], // import {* as utils} from "@/utils/utils"
            '@/utils/request': [['*', 'request']], // import {* as request} from "@/utils/request"
          },
        ],
      }),
    ],
  };
});
